//动态加载外部js
window.loadRemoteScript = (id,src,callback)=>{
    if(!id) {
        return;
    }
    id = id+'-auto-import';
    const existingScript = document.getElementById(id);

    if (!existingScript) {
        const script = document.createElement('script');
        script.src = src;
        script.id = id;
        document.body.appendChild(script);

        script.onload = () => {
            if (callback){
                callback();
            }
        };
    }

    if (existingScript && callback) {
        callback();
    }

}

window.loadRemoteCss = (id,href,callback)=>{
    if(!id) {
        return;
    }
    id = id+'-auto-import';
    const existingScript = document.getElementById(id);

    if (!existingScript) {
        const script = document.createElement('link');
        script.type='text/css'
        script.rel='stylesheet'
        script.href = href;
        script.id = id;
        document.body.appendChild(script);

        script.onload = () => {
            if (callback){
                callback();
            }
        };
    }

    if (existingScript && callback) {
        callback();
    }

}